﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace WebApp.Extensions
{
    public static class RenderHandler
    {
        public static String Render(this bool sino)
        {
            return sino ? "Si" : "No";
        }

        public static String Render(this bool? sinoeredita)
        {
            if(sinoeredita.HasValue == false)
                return "Eredita";
            return Render(sinoeredita.Value);
        }
    }
    
    public partial class SelectListHandler
    {
        public static Dictionary<String, String> SNE = new Dictionary<String, String>() { { "", "Eredita" }, { "true", "Si" }, { "false", "No" } };
        public static Dictionary<String, String> SN = new Dictionary<String, String>() { { "true", "Si" }, { "false", "No" }};

        public static SelectList SiNoEredita(bool? t)
        {
            var selected = "";
            if (t.HasValue)
            {
                selected = t.Value ? "true" : "false";
            }
            return new SelectList(SNE, "Key", "Value", selected);
        }

        public static SelectList SiNoEredita()
        {
            return SiNoEredita(null);
        }

        public static SelectList SiNo(bool t)
        {
            var selected = t ? "true" : "false";
            return new SelectList(SN, "Key", "Value", selected);
        }

        public static SelectList SiNo()
        {
            return SiNo(false);
        }
    }
}